package com.javase.A02;

import java.util.Scanner;

public class A2_3超市购物小程序 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true){
            System.out.println("黑马小商城");
            //数据存储数组
            String[] goods={"牙刷","毛巾","水杯","苹果","香蕉"};
            double[] prices={8.8,10.0,18.8,12.5,15.5};
           //循环输出商品名称和价格
            for (int i = 0; i < goods.length; i++) {
                int k = i+1;
                System.out.println(k+"."+goods[i]+"的价格为："+prices[i]+"元");
            }

            System.out.println("请输入你需要购买商品的序列号：");
            int sequence= sc.nextInt();
            sequence=sequence-1;
            System.out.println("请输入你需要购买商品的数量：");
            int num = sc.nextInt();
            num=num-1;
            double price = sequence * prices[sequence];
            System.out.println("你购买了"+goods[sequence]+"需要花费"+prices[num]+"元");

            System.out.println("需要继续购买请输入Y,否则输入N");
            String YN = sc.next();
            if (YN.equalsIgnoreCase("N")){
                System.out.println("期待您的下次光临");
                break;
            }
        }

    }

}
